#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdint.h>
#include "fat.h"

char Archivo[100] = "path";

int disk_readSector(uint32_t sector, t_Sector *  buf){
	FILE *f;
	int n;
	int sectorSize = sizeof(t_Sector)/sizeof(uint8_t);
	if(f=fopen(Archivo,"r")){
		if (fseek(f,sector*sectorSize,SEEK_SET)==0){
			if (n=fread(buf,sectorSize,1,f)){
				return n;
			}
		}
	}
	fclose(f);
	return 0;
}

int disk_writeSector(uint32_t sector, t_Sector *  buf){
	FILE *f;
	t_Sector *  data;
	int n;
	int sectorSize = sizeof(t_Sector)/sizeof(uint8_t);
	if(f=fopen(Archivo,"r")){
		if (fseek(f,sector*sectorSize,SEEK_SET)==0){
			if (n=fwrite(data,sectorSize,1,f)){
				return n;
			}
		}
	}
	fclose(f);
	return 0;
}
